//
//  CollectionEnum.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/5/27.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import Foundation


public enum CollectionViewModelFromTargetServiceEnum {
    case collection, controller, view, all, reloadCollection, endEdit
}

public enum CollectionViewModelRunServiceEnum {
    case reloadCollection, reloadSection, reloadItem, removeItem, insertItem(IndexPath), insertItemFirst((Int, Int)),  insertItemIndex((Int, Int)), insertItemLast((Int, Int)), toCollectionItemTop, toCollectionItemBottom
}

public extension CollectionViewModelRunServiceEnum {
    func runMethod() -> String {
        var method = ""
        switch self {
        case .reloadCollection:
            method = "serviceReloadCollection"
        case .reloadSection:
            method = "serviceReloadCollectionSection"
        case .reloadItem:
            method = "serviceReloadCollectionItem"
        case .removeItem:
            method = "serviceRemoveCollectionItem"
        case .insertItem(_):
            method = "serviceInsertCollectionItem"
        case .insertItemFirst:
            method = "serviceInsertCollectionItemFirst"
        case .insertItemIndex(_):
            method = "serviceInsertCollectionItemIndex"
        case .insertItemLast:
            method = "serviceInsertCollectionItemLast"
        case .toCollectionItemTop:
            method = "toCollectionItemTop"
        case .toCollectionItemBottom:
            method = "toCollectionItemBottom"
        }
        return method
    }
    
    func runAttachInfo() -> Any? {
        var info: Any?
        switch self {
        case .reloadCollection: break
        case .reloadSection: break
        case .reloadItem: break
        case .removeItem: break
        case .insertItem(let index):
                info = index
        case .insertItemFirst(let index), .insertItemIndex(let index), .insertItemLast(let index):
                info = index
        case .toCollectionItemTop: break
        case .toCollectionItemBottom: break
        }
        return info
    }

    
}
